02. What is an Object?

What is an Object?

ND079 JAVA C1 L2 A01 Lesson Overview- What Is OOP-

Object-Oriented Programming (OOP)

One of the key characteristics of Java is is that it applies an object-oriented approach. This may be different from other languages you may be familiar with.

Benefits of an object-oriented programming approach include:

  • Better software reusability
  • Better maintainability
  • Reduced cost of developing software

What is an Object?

So what is an object? Essentially, it is a data structure that we create that bundles together and encapsulates two key things:

  • The state of the object (represented by variables)
  • The behavior of the object (modeled with methods)

This allows us to interact with the components of our application in more intuitive ways, and it also helps protect the methods and variables from being changed in undesirable ways from elsewhere in our code.

Example: Classroom Object

Object-oriented programming can be confusing at first, but once you see enough examples and work with enough objects yourself, it becomes much more intuitive. Let's have a look at another example, and start to get an idea of what an object looks like in code.

ND079 JAVA C1 L2 A04 What Is An Object-

Which of the following statements about objects are true?

(Select all that apply.)

SOLUTION:
  • We model software as objects to improve readability, maintainability and reusability.
  • Objects have two characteristics: *state* and *behavior*.
  • Objects are an intuitive way to think about developing software.